package com.lgq.service;

import com.lgq.bean.UserExample;
import com.lgq.dao.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @program: stu_info_manager
 * @description:
 * @author: Lin
 * @create: 2019-01-03 16:22
 **/
@Service
public class LoginService {
    /**
     * 自动装配userMapper
     */
    @Autowired
    private UserMapper userMapper;

    /**
     * 校验用户名和密码是否存在于数据库
     * @param username
     * @param password
     * @return 是否存在 存在为true 不存在为false
     */
    public boolean check(String username,String password){
        UserExample userExample=new UserExample();
        UserExample.Criteria criteria=userExample.createCriteria();
        criteria.andUsernameEqualTo(username);
        criteria.andPasswordEqualTo(password);
        long count=userMapper.countByExample(userExample);
        return count!=0;
    }

}
